<?php
namespace app\admin\controller;

use app\common\model\Admin;
use app\common\model\GlobalData;
use think\Controller;
use think\Request;
use think\Session;

class Base extends Controller
{
	protected $page_tag='home';
	protected $page_title="";
	protected $page_desc="";
	protected $sub_menu=[];
	protected $layout='layout';
	
    public function __construct( $request = NULL ) {
    	parent::__construct( $request );
	    if(!Admin::checkLogin()){
		    $this->redirect('Auth/index');
	    }
	    $this->assign('admin_info',Session::get('admin'));
    }
    
    public function fetch( $template = '', $vars = [], $replace = [], $config = [] ) {
    	$vars['page_tag']=$this->page_tag;
	    $vars['page_title']=$this->page_title;
	    $vars['page_desc']=$this->page_desc;
	    $vars['sub_menu']=$this->sub_menu;
	    $vars['action_name']=Request::instance()->action();
	    $this->view->engine->layout('public/'.$this->layout);
	    return parent::fetch( $template, $vars, $replace, $config );
    }
}
